package com.galeno.mapreduce;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;


/**
 * @author galeno
 * @Title:
 * @Description:
 * @date 2021/7/2511:02
 */
public class DriverClass {
    public static void main(String[] args) throws Exception {
        //创建一个配置对象
        Configuration conf=new Configuration();
        conf.set("fs.defaultFS","file:/");
        //初始化一个jobs
        Job job= Job.getInstance(conf,"wordcount");
       // job.setJarByClass(DriverClass.class);
        //设置map类
        job.setMapperClass(WordCountMapper.class);
        //设置reducer类
        job.setReducerClass(WordCountReducer.class);
        //设置map和Reducer类的输出类型
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(IntWritable.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(IntWritable.class);

        //数据的输入路径
        FileInputFormat.setInputPaths(job,new Path("d://word.txt"));

        //输出的结果保存路径
        FileOutputFormat.setOutputPath(job,new Path("d://wcdata"));
        //运行job等待程序运行完毕
        job.waitForCompletion(true);


    }



}
